@extends('admin.public.admin')
@section('main')
<style>
    .queren{
        display:none;
    }
</style>
<div class="mws-panel grid_8">
	<div class="mws-panel-header">
    	<span>订单状态展示</span>
    </div>

    <div class="mws-panel-body no-padding">
    	<table class="mws-datatable-fn mws-table dataTable">

            <thead>
                <tr role="row">
                    <th>ID</th>
                    <th>订单状态名</th>         
                </tr>
             </thead>
            <tbody role="alert" aria-live="polite" aria-relevant="all">

            @foreach($data as $val)
                <tr>
                    
                    <td>{{$val['id']}}</td>
                    <td><input type="text" value="{{$val['name']}}"> <button onclick="save(this,{{$val['id']}})" class="btn btn-success queren">确认</button></td>
                </tr>


            @endforeach

            </tbody>
        </table>
    </div>    	
</div>


<script>
    // 数据修改

    function save(obj,id){

        // 获取用户输入的状态信息

        name=$(obj).prev("input").val();

        // 发送ajax请求

        $.post("/admin/orders/statu/edit",{id:id,name:name,"_token":'{{csrf_token()}}'},function(data){
            // 判断是否成功

            if (data) {
                $(obj).hide();
            }else{
               layer.msg(data.msg, {icon: 5});
            }
        });



    }

    // 鼠标移入确认按钮展示
    $("input[type=text]").focus(function(){
        $(".queren").hide();

        $(this).next("button").show();
    });
</script>
@endsection